﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.Framework.Utils;
using CNVP.Framework;

namespace CNVP.JShop.Web.Controls
{
    public partial class GetReviewList : System.Web.UI.Page
    {
        BLL.CNVP_Review bll = new BLL.CNVP_Review();
        public string productId;
        public int rplistCount = 0;
        public int PageIndex = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            var pid = Request.QueryString["id"];
            if (!string.IsNullOrEmpty(Request.QueryString["Page"]) && Public.IsNumber(Request.QueryString["Page"]))
            {
                PageIndex = Convert.ToInt32(Request.QueryString["Page"]);
            }
            if (String.IsNullOrEmpty(pid) || !Public.IsNumber(pid))
            {
                Response.End();
            }
            else
            {
                productId = pid;
                BLL.CNVP_Review review = new BLL.CNVP_Review();
                LitRecord.Text = review.GetCountOfReview(Convert.ToInt32(pid)).ToString();

            }
            if (!IsPostBack)
            {
                StartLoad(PageIndex);
            }
        }
        protected void StartLoad(int PageIndex)
        {
            int i, j;
            DataTable dt = null;
            int pageNum = 20;
            dt = bll.GetReviewPage(this.GetType().Name, PageIndex, pageNum,Convert.ToInt32(productId), out i, out j, null);
            rpList.DataSource = dt;
            rpList.DataBind();
            LitPager.Text = Paginator.Pagination(PageIndex, i, j);
        }
    }
}